//
//  YJBLoginPhoneNumView.m
//  YunJiaBaoFirst
//
//  Created by 腾云小白龍 on 16/7/6.
//  Copyright © 2016年 腾云小白龍. All rights reserved.
//

#import "YJBLoginPhoneNumView.h"

@interface YJBLoginPhoneNumView ()

@property (nonatomic ,strong) UIImageView *phoneNumImgView;
@property (nonatomic ,strong) UIImageView *passwordImgView;

@end

@implementation YJBLoginPhoneNumView

-(UIView *)YJBLoginPhoneNumView:(YJBLoginPhoneNumView *)view  withType:(BOOL)isLoginView{
    
    UIView *contentView = [[UIView alloc]initWithFrame:view.bounds];
    [view addSubview:contentView];
    
    CGFloat scale = contentView.frame.size.height /190;
    
    UIView *phoneNumContView = ({
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(15,scale*30, contentView.frame.size.width - 15 - 50,scale* 45)];
        view.backgroundColor = KColorWithRGBA(140, 137, 138, 1);
        view.layer.cornerRadius = 1;
        view.layer.masksToBounds = YES;
        view;
    });
    [contentView addSubview:phoneNumContView];

    
    self.phoneNumImgView = ({
        UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 50, scale* 45)];
        imgView.image = [UIImage imageNamed:@"phoneNum"];
        [phoneNumContView addSubview:imgView];
        imgView;
    });
    
    self.phoneNumTextField = ({
        UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.phoneNumImgView.frame) + 10, 0, contentView.frame.size.width - 50,scale* 45)];
        textField.placeholder = @"请输入您的手机号";
        textField.textAlignment = NSTextAlignmentLeft;
        textField.keyboardType = UIKeyboardTypePhonePad;
        textField.font = [UIFont systemFontOfSize:14];
        [textField setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
        [phoneNumContView addSubview:textField];
        textField;
    });
    
    
    UIView *passWordNumContView = ({
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(15, CGRectGetMaxY(phoneNumContView.frame) +scale* 20, contentView.frame.size.width - 15 - 50,scale* 45)];
        view.backgroundColor = KColorWithRGBA(140, 137, 138, 1);
        view.layer.cornerRadius = 1;
        view.layer.masksToBounds = YES;
        view;
    });
    [contentView addSubview:passWordNumContView];

    
    self.passwordImgView = ({
        UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 50,scale* 45)];
        imgView.image = [UIImage imageNamed:@"passWord"];
        [passWordNumContView addSubview:imgView];
        imgView.contentMode = UIViewContentModeScaleToFill;
        imgView;
    });
    
    self.passwordTextField = ({
        UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.passwordImgView.frame) + 10, 0, contentView.frame.size.width - 50,scale* 45)];
        textField.placeholder = @"请输入您的密码";
        textField.textAlignment = NSTextAlignmentLeft;
        textField.secureTextEntry = YES;
        [textField setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
        textField.font = [UIFont systemFontOfSize:14];
        [passWordNumContView addSubview:textField];
        textField;
    });
    
    
    self.loginBtn = ({
        UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(CGRectGetMaxX(passWordNumContView.frame), CGRectGetMaxY(phoneNumContView.frame) +scale* 20, 60,scale* 30)];
        [button setImage:[UIImage imageNamed:@"loginBtn"] forState:UIControlStateNormal];
        button.imageEdgeInsets = UIEdgeInsetsMake(3, 5, -12, 15);
        
        button;
    });
    [contentView addSubview:self.loginBtn];
    
    
    self.createNewUserBtn = ({
        UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(15, CGRectGetMaxY(passWordNumContView.frame) + 10, 100,scale* 30)];
        [button setTitle:@"注册" forState:UIControlStateNormal];
        [button setTitleColor:KColorWithRGBA(140, 137, 138, 1) forState:UIControlStateNormal];
        [button setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
        button.titleLabel.font = [UIFont systemFontOfSize:18];
        button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        
        button;
    });
    [contentView addSubview:self.createNewUserBtn];
    
    
     self.forgetPassWordBtn = ({
         UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(CGRectGetMaxX(passWordNumContView.frame) - 100, CGRectGetMaxY(passWordNumContView.frame) + 10, 100,scale* 30)];
         [button setTitle:@"忘记密码" forState:UIControlStateNormal];
         [button setTitleColor:KColorWithRGBA(140, 137, 138, 1) forState:UIControlStateNormal];
         [button setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
         button.titleLabel.font = [UIFont systemFontOfSize:18];
         button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
         
         button;
    });
    [contentView addSubview:self.forgetPassWordBtn];

    
    return contentView;
    
}



#pragma mark --//注册
-(UIView*)YJBRegisterView:(YJBLoginPhoneNumView *)view{
    
    UIView *contentView = [[UIView alloc]initWithFrame:view.bounds];
    [view addSubview:contentView];
    
    CGFloat scaleH = contentView.frame.size.height /180;
    CGFloat fontSize = 14;
    if ([UIScreen mainScreen].bounds.size.height == 480) {
        fontSize = 12;
    }
    UILabel *phoneLabel = ({
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 40,scaleH* 40)];
        label.text = @"+ 86";
        label.font =[UIFont boldSystemFontOfSize:fontSize + 2];
        [contentView addSubview:label];
        label;
    });
    
    self.phoneNumTextField = ({
        UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(CGRectGetMaxX(phoneLabel.frame) + 10, 10, contentView.frame.size.width - 100,scaleH* 40)];
        textField.placeholder = @"请输入您的手机号";
        textField.textAlignment = NSTextAlignmentLeft;
        textField.keyboardType = UIKeyboardTypePhonePad;
        textField.font = [UIFont systemFontOfSize:fontSize];
        [contentView addSubview:textField];
        textField;
    });
    
    
    UIView *lineViewNum = ({
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(phoneLabel.frame), contentView.frame.size.width - 20, 1.5)];
        view.backgroundColor = KColorWithRGBA(45, 45, 45, 1);
        view;
    });
    [contentView addSubview:lineViewNum];
    
    
    self.verfyCodeTextField = ({
        UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(lineViewNum.frame) + 10, view.frame.size.width* 130/345,scaleH* 40)];
        textField.placeholder = @"请输入验证码";
        textField.textAlignment = NSTextAlignmentCenter;
        textField.font = [UIFont systemFontOfSize:fontSize];
        [contentView addSubview:textField];
        textField.keyboardType = UIKeyboardTypePhonePad;
        textField;
    });
    
    self.verfyCodeButton = ({
        UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(contentView.frame.size.width - 10 - scaleH* 90, CGRectGetMaxY(lineViewNum.frame) + 12,scaleH* 90,scaleH* 30)];
        [button setTitle:@"获取验证码" forState:UIControlStateNormal];
        [button setTitleColor:KColorWithRGBA(192, 177, 178, 1) forState:UIControlStateNormal];
        [button setTitleColor:[UIColor lightGrayColor] forState:UIControlStateHighlighted];
        button.titleLabel.font = [UIFont systemFontOfSize:fontSize];
        [button setBackgroundColor:KMainColor];
        button.layer.cornerRadius = 5;
        button;
    });
    [contentView addSubview:self.verfyCodeButton];
    
    UIView *lineViewVerfyCode = ({
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(self.verfyCodeTextField.frame), contentView.frame.size.width - 20, 1.5)];
        view.backgroundColor = KColorWithRGBA(45, 45, 45, 1);
        view;
    });
    [contentView addSubview:lineViewVerfyCode];
    
    
    self.passwordTextField = ({
        UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(self.verfyCodeTextField.frame) + 15, contentView.frame.size.width - 100,scaleH* 40)];
        textField.placeholder = @"请输入您的密码";
        textField.secureTextEntry = YES;
        textField.textAlignment = NSTextAlignmentLeft;
        textField.font = [UIFont systemFontOfSize:fontSize];
        [contentView addSubview:textField];
        textField;
    });
    
    
    UIView *lineViewPW = ({
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(self.passwordTextField.frame), contentView.frame.size.width - 20, 1.5)];
        view.backgroundColor = KColorWithRGBA(45, 45, 45, 1);
        view;
    });
    [contentView addSubview:lineViewPW];
    
    
    return contentView;
    
}



@end
